#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
	int data;
	struct node *left,*right;
}BTtree;
BTtree *CreatBtree(int a[],int n)
{
	BTtree *p,*q,*pa,*root=NULL;
	for(int i=0;i<n;i++)
	{
		p=(BTtree *)malloc(sizeof(BTtree));
		p->data=a[i];
		p->left=p->right=NULL;
		if(!i)
			root=p;
		else
		{
			q=root;
			while(q)
			{
				pa=q;
				if(q->data>p->data)
					q=q->left;
				else
					q=q->right;
			}
            if(pa->data>p->data)
				pa->left=p;
			else
				pa->right=p;
		}
	}
	return root;
}
void Forder(BTtree *root)
{
	if(root)
	{
		//printf("%5d",root->data);
		Forder(root->left);
		printf("%5d",root->data);
		Forder(root->right);
	}
}
int main()
{
	int a[6]={3,2,5,7,4,8};
	BTtree *root;
	root=CreatBtree(a,6);
	Forder(root);
	printf("\n");
	return 0;
}